function login() {
    window.location.href = "index.html";
}
function register() {
    window.location.href = "register.html";
}
function back() {
    history.back();
}

/*tab切换*/
function tabs(obj1, obj2) {
    $(document).on("click", obj1, function () {
        var index_ = $(obj1).index(this);
      
        $(this).addClass("aui-active");
        $(this).siblings().removeClass("aui-active");
        $(obj2).eq(index_).removeClass("aui-hide").siblings().addClass("aui-hide");
    })
}
$(function(){
	getIndex();
});
var baseurl = 'http://kt.zhangzhengjiang.top/api/';
var static_url = 'http://kt.zhangzhengjiang.top/';
function getIndex(){
		 layer.open({
		    type: 2
		    ,content: '正在加载...'
		  });
		$.ajax({
			url:baseurl+'index/index',
			type:'post',
			success:function(res){
				layer.closeAll();
				console.log(res);
				if(res.code == 1){
				  //轮播
				  var banner = res.data.banner;
				  var banner_html = '';
				  for (var i = 0; i < banner.length; i++) {
				  	
				  		banner_html+='<li style="display: table-cell; vertical-align: top; width: 375px;"><a href="'+banner[i].url+'"><img src="'+static_url+banner[i].image+'"/></a></li>';
				  	
				  }
				  $('#lbt').html(banner_html);
				  //活动
				  var active = res.data.active;
				  var active_html = '<a href="'+active.url+'"><img src="'+active.image+'" alt="" width="100%" height="100px"/></a>';
				  $('#active').html(active_html);
				  //跟课辅导
				  var gkfd = res.data.kkfd;
				  var gkfd_html = '';
				  for (var i = 0; i < gkfd.length; i++) {
				  		gkfd_html+='<div class="aui-col-xs-6 aui-padded-t-5 aui-padded-b-5"><a href="itemDetail.html?kid='+gkfd[i].id+'"><img src="'+static_url+gkfd[i].images+'" alt="" class="aui-iconfont aui-class-img"></a></div>';
				  }
				  $('#gkfd').html(gkfd_html);
				  //教师课堂
				  var teacherkt = res.data.teacherkt;
				  var teacherkt_html = '';
				  for (var i = 0; i < teacherkt.length; i++) {
				  		teacherkt_html+='<a href="itemDetail.html?kid='+teacherkt[i].id+'"><li class="aui-list-item aui-list-item-middle aui-background-white"><div class="aui-media-list-item-inner" style="align-items: flex-start;">';
						teacherkt_html+='<div class="aui-list-item-media wechat-avatar aui-list-media-img" style="width: 4rem;"><img src="'+static_url+teacherkt[i].images+'" class="aui-border-radius"></div>';
	                    teacherkt_html+='<div class="aui-list-item-inner aui-padded-l-10"><div class="aui-list-item-text"><div class="aui-list-item-title"><span class="aui-font-weight">'+teacherkt[i].title+'</span></div></div>';
	                    teacherkt_html+='<div class="aui-text-default aui-margin-t-5"><p class="aui-price aui-font-size-14 aui-margin-t-10"> 限时免费<span class="aui-right-now aui-pull-right">立即学习</span></p></div></div></div></li></a>';
	                    
				  }
				  $('#jskt').append(teacherkt_html);
				  //老师风采
				  var teacher = res.data.teacher;
				  var teacher_html = '';
				  for (var i = 0; i < teacher.length; i++) {
				        teacher_html+='<a href="user-teacher.html?tid'+teacher[i].id+'"><li class="aui-list-item aui-list-item-middle aui-background-white ">';
				        	teacher_html+='<div class="aui-media-list-item-inner" style="align-items: flex-start;">';
				                teacher_html+='<div class="aui-list-item-media wechat-avatar aui-list-media-img" style="width: 4rem;">';
				                    teacher_html+='<img src="'+static_url+teacher[i].image+'" class="aui-border-radius">';
				                teacher_html+='</div>';
				                teacher_html+='<div class="aui-list-item-inner aui-padded-l-10">';
				                    teacher_html+='<div class="aui-list-item-text">';
				                        teacher_html+='<div class="aui-list-item-title">'+teacher[i].name+'</div>';
				                    teacher_html+='</div>';
				                    teacher_html+='<div class="aui-text-default aui-margin-t-5">';
				                        teacher_html+='<p class="aui-descr-con aui-ellipsis-2 aui-background-white">'+teacher[i].content+'</p>';
				                        teacher_html+='<p class="aui-font-size-12 aui-margin-t-10">';
				                        	// teacher_html+='<span>13.7万</span> <span>20课</span>';
				                        teacher_html+='</p>';
				                    teacher_html+='</div>';
				                teacher_html+='</div>';
				            teacher_html+='</div>';
				        teacher_html+='</li></a>';
				  }
				  $('#teacher').html(teacher_html);
				}else{
					layer.open({
						content: res.msg
						,skin: 'msg'
						,time: 2 ,//2秒后自动关闭
						
					});
				}
			}
		})
}
